package com.woniu.service.contentService.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.mapper.contentService.ColumnMapper;
import com.woniu.model.contentMService.entity.ColumnM;
import com.woniu.service.contentService.IColumnMService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 栏目表 服务实现类
 * </p>
 *
 * @author 作者
 * @since 2023-10-20
 */
@Service
public class ColumnMServiceImpl extends ServiceImpl<ColumnMapper, ColumnM> implements IColumnMService {

    @Autowired
    private ColumnMapper columnMapper;

    @Override
    public IPage<ColumnM> findByType(Integer pageNum, Integer pageSize) {

        Page<ColumnM> page = Page.of(pageNum, pageSize);
        LambdaQueryWrapper<ColumnM> wrapper = Wrappers.lambdaQuery(ColumnM.class);
        wrapper.select();
        wrapper.orderByDesc(ColumnM::getSequence);
        Page<ColumnM> pageData = this.page(page, wrapper);
        return pageData;
    }

    @Override
    public  int deleteById(Long id) {
       return columnMapper.deleteById(id);
    }
}
